package test;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		PersonSortable[] p = new PersonSortable[n];
		for (int i = 0; i < n; i++) 
		{
			p[i] = new PersonSortable(in.next(), in.nextInt());
		}
		Arrays.sort(p,new NameComparator());
		System.out.println("NameComparator:sort");
		for (int i = 0; i < n; i++) 
		{
			System.out.println(p[i]);
		}
		Arrays.sort(p,new AgeComparator());
		System.out.println("AgeComparator:sort");
		for (int i = 0; i < n; i++) 
		{
			System.out.println(p[i]);
		}
		System.out.println(Arrays.toString(NameComparator.class.getInterfaces()));
		System.out.println(Arrays.toString(AgeComparator.class.getInterfaces()));
		in.close();
	}
}
